'use strict';
const BaseController = require('./base');
const {Op} = require("sequelize");
const serviceName = 'product';
// 继承baseController 并且指定serviceName
class RouterController extends BaseController {
  constructor(ctx) {
    super(ctx, serviceName);
  }
  getPageQuery(query) {
    const where = {};
    if (query.categoryId) {
      where.category_id = query.categoryId
    }
    console.log(query.keyword, 'keyword')
    if (query.keyword) {
      where.name = {
        [Op.like]: `%${query.keyword}%`,
      }
    }
    if (query.type) {
      where.type = query.type
    }
    return where;
  }
}
module.exports = RouterController;
